/*
 * Copyright (C) 2011, 2012 Moravská zemská knihovna v Brně / Moravian Library in Brno
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package cz.mzk.oai.provider;

import cz.mzk.oai.provider.response.GetRecord;
import cz.mzk.oai.provider.response.Identify;
import cz.mzk.oai.provider.response.ListIdentifiers;
import cz.mzk.oai.provider.response.ListMetadataFormats;
import cz.mzk.oai.provider.response.ListRecords;
import cz.mzk.oai.provider.response.ListSets;
import cz.mzk.oai.provider.response.OaiVerbResponse;
import java.io.IOException;
import java.util.Map;

/**
 *
 * @author Martin Řehánek (rehan at mzk.cz)
 */
public class VerbFactory {

    static OaiVerbResponse getVerbResponse(String verbStr, Map<String, String[]> parameters, String baseUrl) throws OaiException, IOException {
        if ("Identify".equals(verbStr)) {
            return new Identify(parameters, baseUrl);
        }
        if ("ListSets".equals(verbStr)) {
            return new ListSets(parameters, baseUrl);
        }
        if ("GetRecord".equals(verbStr)) {
            return new GetRecord(parameters, baseUrl);
        }
        if ("ListMetadataFormats".equals(verbStr)) {
            return new ListMetadataFormats(parameters, baseUrl);
        }
        if ("ListIdentifiers".equals(verbStr)) {
            return new ListIdentifiers(parameters, baseUrl);
        }
        if ("ListRecords".equals(verbStr)) {
            return new ListRecords(parameters, baseUrl);
        }
        throw new OaiException(ErrorCode.badVerb, "Illegal verb '" + verbStr + "'");
    }
}
